package ModelLag;



import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class DVDTest.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class DVDTest
{
    
    
    /**
     * Default constructor for test class DVDTest
     */
    public DVDTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
        
    }
    
    @Test
    public void testIfTitleSet(){
        DVD dvd1 = new DVD("12345678", "Rambo III", "Sylvester Stallone", "1990");
        dvd1.setTitle("Die Hard");
        
        assertEquals("Die Hard", dvd1.getTitle());
        
    }
    
    @Test
    public void testIfArtistSet(){
        DVD dvd1 = new DVD("12345678", "Rambo III", "Sylvester Stallone", "1990");
        dvd1.setArtist("Bruce Willis");
        
        assertEquals("Bruce Willis", dvd1.getArtist());
    }
    
    @Test
    public void testIfPublicationDateSet(){
        DVD dvd1 = new DVD("12345678", "Rambo III", "Sylvester Stallone", "1990");
        dvd1.setPublicationDate("1980");
        
        assertEquals("1980", dvd1.getPublicationDate());       
    }
    
    @Test
    public void testGetBarcode(){
        DVD dvd1 = new DVD("12345678", "Rambo III", "Sylvester Stallone", "1990");
        
        assertEquals("12345678", dvd1.getBarcode());
    }
    
    @Test
    public void testIfCopyAdded(){
        DVD dvd1 = new DVD("12345678", "Rambo III", "Sylvester Stallone", "1990");
        Copy copy1 = new Copy("666","19-09-2014",199.95);
        dvd1.addCopy(copy1);
        
        assertEquals(copy1, dvd1.findCopy("666"));
            
    }
    
    @Test
    public void testIfMultipleCopiesAdded(){
        DVD dvd1 = new DVD("12345678", "Rambo III", "Sylvester Stallone", "1990");
        
        Copy copy1 = new Copy("666","19-09-2014",199.95);
        Copy copy2 = new Copy("777","19-09-2010",100.00);
        Copy copy3 = new Copy("888","19-09-2006",150.00);
        
        dvd1.addCopy(copy1);
        dvd1.addCopy(copy2);
        dvd1.addCopy(copy3);
        
        assertEquals(copy2, dvd1.findCopy("777")); 
    }
    
    @Test
    public void testIfCopyContained(){
       DVD dvd1 = new DVD("12345678", "Rambo III", "Sylvester Stallone", "1990");
       
       Copy copy1 = new Copy("666","19-09-2014",199.95);
       
       dvd1.addCopy(copy1);
       
       assertEquals(true, dvd1.containsCopy("666"));
    }
    
    @Test
    public void testIfCopyNotContained(){
        DVD dvd1 = new DVD("12345678", "Rambo III", "Sylvester Stallone", "1990");
        assertEquals(false, dvd1.containsCopy("666"));
    }
    
    @Test
    public void testIfCopyDeleted(){
        DVD dvd1 = new DVD("12345678", "Rambo III", "Sylvester Stallone", "1990");
       
        Copy copy1 = new Copy("666","19-09-2014",199.95);
        
        dvd1.addCopy(copy1);
        dvd1.deleteCopy("666");
        
        assertEquals(false, dvd1.containsCopy("666"));
    }
    
    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
    }
}
